<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>值班管理</title>

<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/back/css/x-admin.css"
	media="all">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/back/css/pag.css" media="all">
<script src="${pageContext.request.contextPath}/assets/layer/layer.js"></script>
<script src="${pageContext.request.contextPath}/back/lib/layui/layui.js"></script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/assets/layui/css/layui.css">
<script
	src="${pageContext.request.contextPath}/back/lib/bootstrap/js/bootstrap.min.js"></script>
<link
	href="${pageContext.request.contextPath}/back/lib/bootstrap/css/bootstrap.min.css"
	rel="stylesheet">
</head>
<body>
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a><cite>首页</cite></a> <a><cite>值班管理</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<form class="layui-form x-center" action="" style="width: 85%">
			<div class="layui-form-pane">
				<div class="layui-form-item">

					<div class="layui-input-inline" style="width: 200px">
						<input type="text" name="link" placeholder="搜索" autocomplete="off"
							class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 80px">
						<button class="layui-btn" lay-submit="" lay-filter="*">搜索</button>
					</div>
				</div>
			</div>
		</form>
		<div class="tools">
			<ul class="toolbar">
				<li onclick="change()" data-toggle="modal"><span><img
						src="${pageContext.request.contextPath}/back/images/t01.png" /></span>添加</li>
			</ul>
			<span class="x-right" style="line-height: 25px">值班记录：<span
				id="count"></span>条
			</span>
		</div>
		<table class="tablelist">
			<thead>
				<tr>
					<th><input onclick="selectAll()" type="checkbox"
						name="controlAll" style="" id="controlAll"></th>
					<th>编号</th>
					<th>医生</th>
					<th>值班日期</th>
					<th>值班状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<!-- 判断是否为空数据 -->
				<c:if test="${list==null}">
					<jsp:forward page="${pageContext.request.contextPath}/duty"></jsp:forward>
				</c:if>
				<c:forEach items="${list}" var="duty">
					<tr>
						<td><input onclick="selectAll()" type="checkbox"
							name="controlAll" style="" id="controlAll"></td>
						<td>${duty.dutyid}</td>
						<td>${duty.doctorName}</td>
						<td>${duty.dutydate}</td>
						<td>${duty.dutystate==1?"值班中":"没值班"}</td>
						<td class="td-manage"><a title="编辑" href="javascript:;"
							onclick="changeUpd(this)" class="ml-5"
							style="text-decoration: none"> <i class="layui-icon">&#xe642;</i>
						</a>
					</tr>

				</c:forEach>


			</tbody>
		</table>
		<!-- 这里放我们的修改遮罩层 -->
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="modal fade" id="modal-container-upd" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<!-- 通过样式设置层的宽度 -->
					<div class="modal-dialog" style="width: 900px">
						<div class="modal-content">

							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">×</button>
								<h4 class="modal-title" id="myModalLabel">修改值班信息</h4>
							</div>
							<!-- 表单开始  action ="url" 一个动态可以接受当前表单数据的地址  xx.php /xx.jsp /xx.action xx.do 某个servlet文件... -->
							<form class="form-horizontal" role="form" action="" method="post">
								<div class="modal-body">

									<div class="form-group">
										<label for="dutyid1" class="col-sm-2 control-label">值班编号</label>
										<div class="col-sm-8">
											<input type="text" required="required" class="form-control"
												name="dutyid" id="dutyid1" readonly="readonly" />
										</div>
									</div>

									<div class="form-group">
										<label for="outpatientservicetypeid"
											class="col-sm-2 control-label">医生名称</label>
										<div class="col-sm-8">
											<!-- <input type="text" required="required" class="form-control"
												name="keshiId" id="keshiId" /> -->
											<select id="doctorid11"
												name="doctorid" class="form-control">
												<option value="1">蔡明</option>
												<option value="2">张平生</option>
												<option value="3">杨世杰</option>
												<option value="4">郭何伟</option>
												<option value="5">胡昌胜</option>
												<option value="6">梁丽萍</option>
												<option value="7">吴明阳</option>
												<option value="8">阿猪哥</option>
												<option value="9">秦明</option>
												
											</select>
										</div>
									</div>


									<div class="form-group">
										<label for="outpatientservicetypeid"
											class="col-sm-2 control-label">值班时间</label>
										<div class="col-sm-8">
											<!-- <input type="text" required="required" class="form-control"
												name="keshiId" id="keshiId" /> -->
											 <input type="checkbox" value="星期一" name="dutydate1" id="dutydate1" >星期一
											 <input type="checkbox" value="星期二" name="dutydate1" id="dutydate1" >星期二
											 <input type="checkbox" value="星期三" name="dutydate1" id="dutydate1" >星期三
											  <input type="checkbox" value="星期四" name="dutydate1" id="dutydate1" >星期四
											   <input type="checkbox" value="星期五" name="dutydate1" id="dutydate1" >星期五
											    <input type="checkbox" value="星期六" name="dutydate1" id="dutydate1" >星期六
											     <input type="checkbox" value="星期日" name="dutydate1" id="dutydate1" >星期日
											 <!-- <select id="outpatientservicetypeid1"
												name="outpatientservicetypeid" class="form-control" >
												<option value="星期一">星期一</option>
												<option value="星期二">星期二</option>
												<option value="星期三">星期三</option>
												<option value="星期四">星期四</option>
												<option value="星期五">星期五</option>
												<option value="星期六">星期六</option>
												<option value="星期日">星期日</option>
											</select>  -->
										</div>
									</div>

									<div class="form-group">
										<label for="dutystate" class="col-sm-2 control-label">医生状态</label>
										<div class="col-sm-8">
											<!-- <input type="text" required="required" class="form-control"
												name="doctorSex" id="doctorSex" /> -->
											<select id="state" name="state"
												class="form-control">
												<option value="1">值班中</option>
												<option value="0">没值班</option>
											</select>
										</div>
									</div>

								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-default"
										data-dismiss="modal">关闭</button>
									<button type="submit" class="btn btn-primary" id="upd">修改</button>
								</div>
							</form>
							<!-- 表单结束 -->
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 修改遮罩层的结束 -->
		<!-- 这里放我们的添加遮罩层 -->
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="modal fade" id="modal-container-534629" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<!-- 通过样式设置层的宽度 -->
					<div class="modal-dialog" style="width: 900px">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">×</button>
								<h4 class="modal-title" id="myModalLabel">添加值班</h4>
							</div>
							<!-- 表单开始  action ="url" 一个动态可以接受当前表单数据的地址  xx.php /xx.jsp /xx.action xx.do 某个servlet文件... -->
							<form class="form-horizontal" role="form" action="" method="post">
								<div class="modal-body">

									<div class="form-group">
										<label for="outpatientservicetypeid"
											class="col-sm-2 control-label">医生名称</label>
										<div class="col-sm-8">
											<!-- <input type="text" required="required" class="form-control"
												name="keshiId" id="keshiId" /> -->
											<select id="doctorid1"
												name="doctorid1" class="form-control">
												<option value="1">蔡明</option>
												<option value="2">张平生</option>
												<option value="3">杨世杰</option>
												<option value="4">郭何伟</option>
												<option value="5">胡昌胜</option>
												<option value="6">梁丽萍</option>
												<option value="7">吴明阳</option>
												<option value="8">阿猪哥</option>
												<option value="9">秦明</option>
												<option value="10">郭中杰</option>
												<option value="11">黄添航</option>
												<option value="12">林依稀</option>
											</select>
										</div>
									</div>
									
										<div class="form-group">
										<label for="outpatientservicetypeid"
											class="col-sm-2 control-label">值班时间</label>
										<div class="col-sm-8">
											<!-- <input type="text" required="required" class="form-control"
												name="keshiId" id="keshiId" /> -->
											 <input type="checkbox" value="星期一" name="dutydate" id="dutydate" >星期一
											 <input type="checkbox" value="星期二" name="dutydate" id="dutydate" >星期二
											 <input type="checkbox" value="星期三" name="dutydate" id="dutydate" >星期三
											  <input type="checkbox" value="星期四" name="dutydate" id="dutydate" >星期四
											   <input type="checkbox" value="星期五" name="dutydate" id="dutydate" >星期五
											    <input type="checkbox" value="星期六" name="dutydate" id="dutydate" >星期六
											     <input type="checkbox" value="星期日" name="dutydate" id="dutydate" >星期日
											 <!-- <select id="outpatientservicetypeid1"
												name="outpatientservicetypeid" class="form-control" >
												<option value="星期一">星期一</option>
												<option value="星期二">星期二</option>
												<option value="星期三">星期三</option>
												<option value="星期四">星期四</option>
												<option value="星期五">星期五</option>
												<option value="星期六">星期六</option>
												<option value="星期日">星期日</option>
											</select>  -->
										</div>
									</div>
									
									<div class="form-group">
										<label for="dutystate" class="col-sm-2 control-label">医生状态</label>
										<div class="col-sm-8">
											<!-- <input type="text" required="required" class="form-control"
												name="doctorSex" id="doctorSex" /> -->
											<select id="dutystate" name="dutystate" class="form-control">
												<option value="1">值班中</option>
												<option value="0">没值班</option>
											</select>
										</div>
									</div>

								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-default"
										data-dismiss="modal">关闭</button>
									<button type="submit" class="btn btn-primary" id="add">添加</button>
								</div>
							</form>
							<!-- 表单结束 -->
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 添加遮罩层的结束 -->
		<!-- <div class="page" v-show="show">
			<div class="pagelist">
				<span class="jump">上一页</span> <span class="jump">1</span> <span
					class="jump">下一页</span> <span class="jumppoint">跳转到：</span> <span
					class="jumpinp"> <input type="text">
				</span> <span class="jump gobtn">GO</span>
			</div>
		</div> -->
	</div>
	<br />
	<br />
	<br />
	<script
		src="${pageContext.request.contextPath}/back/./lib/layui/layui.js"
		charset="utf-8"></script>
	<script src="${pageContext.request.contextPath}/back/./js/x-layui.js"
		charset="utf-8"></script>
		<script src="${pageContext.request.contextPath}/assets/layui/layui.js" charset="utf-8"></script> 
	<%-- <script src="${pageContext.request.contextPath}/back/js/jquery2.js"
		charset="utf-8"></script>
	<script src="${pageContext.request.contextPath}/back/js/js.js"
		charset="utf-8"></script> --%>
		<script type="text/javascript">
		$(function(){
			  layui.use(['laypage', 'layer'], function(){
				  var laypage = layui.laypage
				  ,layer = layui.layer;
				
				//完整功能
				  laypage.render({
				    elem: 'pageDiv'
				    ,count: ${requestScope.count}
				    ,curr:${requestScope.page}
				   ,limit:10
				    ,layout: ['count', 'prev', 'page','limit','next', 'skip']
				    ,jump: function(obj,first){
				    //首次不执行
				      if(!first){
				    	  $.ajax({
				    		  url:"${pageContext.request.contextPath}/dutyPage/"+obj.curr+"/"+obj.limit,
				    		  type:"get",
				    		  success:function(medicineList){
				    			 		$("tbody").empty();
				    				      //模拟渲染
				    				      var innerHtml="";
				    				     
				    				      $.each(medicineList,function(index,medicine){
				    				    	  innerHtml+="<tr>"+
				    				    	  "<td><input onclick='selectAll()'"+" type='checkbox'"+
			    								"name='controlAll'"+"id='controlAll'></td>"+
			    								"<td>"+duty.dutyid+"</td>"+
			    								"<td>"+duty.doctorName+"</td>"+
			    								"<td>"+duty.dutydate+"</td>"+
			    								"<td>"+duty.dutystate+"</td>"+
			    								
			    								"<td class='td-manage'><a title='编辑'  onclick='changeUpd(this)' class='ml-5' style='text-decoration: none'> <iclass='layui-icon'>&#xe642;</i></a> <a title='删除' href='javascript:;' class='delMedicine' style='text-decoration: none'> <i class='layui-icon'>&#xe640;</i></a></td>"+
			    								"</tr>";
				    				      })
				    				    	  
				    				      
				    				     $("tbody").html(innerHtml);
				    				    }
				    				  });
				    		  }
				    	  }
				  });
				}); 
		});
		 
	</script> 
	<script type="text/javascript">
		layui.use([ 'laydate', 'element', 'laypage', 'layer' ], function() {
			$ = layui.jquery;//jquery
			lement = layui.element();//面包导航
			laypage = layui.laypage;//分页
			layer = layui.layer;//弹出层

		});

		//添加的模态
		function change() {
			$("#modal-container-534629").modal("show");
			/* $("#doctorId").val(doctorname);
			$("#doctorsex").val(doctorsex);
			$("#outpatientservicetypeid").val(outpatientservicetypeid);
			$("#jobtime").val(jobtime); */

			$("#add")
					.click(
						
							   
						
							function() {
								obj = document.getElementsByName("dutydate");
							    check_val = [];
							    var dutyDate="";
							    for(k in obj){
							        if(obj[k].checked){
							            check_val.push(obj[k].value);
							        }
							    }
							    dutyDate= check_val.join("，");
							    
							
								$
										.ajax({
											url : "${pageContext.request.contextPath}/addDuty",

											type : "post", //增加操作  post方法
											contentType : "application/json",
											data : JSON
													.stringify({
														doctorid : $(
																"#doctorid1")
																.val(),
														dutydate : dutyDate,
														dutystate : $(
																"#dutystate")
																.val(),
													}),
											success : function(result) {
												if (result == 1) {
													location.href = "${pageContext.request.contextPath}/dutyListBack"
												}
											}
										});

							});
		}
		//修改的模态
		function changeUpd(e) {
			
		   
			$("#modal-container-upd").modal("show");
			var dutyid = $(e).parents("tr").find("td").eq(1).text();
			var doctorid = $(e).parents("tr").find("td").eq(2).text();
			var dutyDate1 = $(e).parents("tr").find("td").eq(3).text();
			 var dutyState1 = $(e).parents("tr").find("td").eq(4).text(); 
			 $("#dutyid1").val(dutyid);
			$("#doctorid11").val(doctorid);
			$("#dutyDate1").val(dutyDate1);
			 
			
			$("#upd")
					.click(
							function() {
								 
								
								obj = document.getElementsByName("dutydate1");
							    check_val = [];
							    var dutyDate="";
							    for(k in obj){
							        if(obj[k].checked){
							            check_val.push(obj[k].value);
							        }
							    }
							    dutyDate= check_val.join("，");
								$
										.ajax({
											url : "${pageContext.request.contextPath}/dutyUpd/"+$("#dutyid1").val(),
											type : "put", //修改操作  put方法
											contentType : "application/json",
											data : JSON
													.stringify({
														dutyid : $("#dutyid1")
																.val(),
														doctorid : $(
																"#doctorid11")
																.val(),														
														dutydate : dutyDate,
														dutystate : $("#state").val()
													}),
													success : function(result) {
														if (result) {
															window.location.reload();
												}
											}
										});

							});
		}
		/*用户-添加*/
		function user_management_add(title, url, w, h) {
			x_admin_show(title, url, w, h);
		}

		/*用户-查看*/
		function user_management_show(title, url, id, w, h) {
			x_admin_show(title, url, w, h);
		}

		/*用户-停用*/
		function member_stop(obj, id) {
			layer
					.confirm(
							'确认要停用吗？',
							function(index) {
								//发异步把用户状态进行更改
								$(obj)
										.parents("tr")
										.find(".td-manage")
										.prepend(
												'<a style="text-decoration:none" onClick="member_start(this,id)" href="${pageContext.request.contextPath}/back/javascript:;" title="启用"><i class="layui-icon">&#xe62f;</i></a>');
								$(obj).parents("tr").find(".td-status").html(
										'<button class="sp3">已停用</button>');
								$(obj).remove();
								layer.msg('已停用!', {
									icon : 5,
									time : 1000
								});
							});
		}

		// 用户-编辑
		function user_management_edit(title, url, id, w, h) {
			x_admin_show(title, url, w, h);
		}
		/*密码-修改*/
		function user_management_password(title, url, id, w, h) {
			x_admin_show(title, url, w, h);
		}

		$('.tablelist tbody tr:odd').addClass('odd');
	</script>


</body>
</html>